home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
music4c.sit
/
Music4C Folder
/
orchestras
/
HoweExample3.c
< prev
next >
Wrap
Text File
|
1990-08-07
|
2KB
|
108 lines
/*
* ⌐ Graeme Gerrard 1990
* Faculty of Music, University of Melbourne
* Parkville Victoria 3052 Australia.
*
* ARPANET: grae@murdu.ucs.unimelb.edu.au
* telephone: (613) 344 4127, Fax: (613) 344 5346
*/
#include "Music4C.h"
#include <math.h>
#include "ugens.h"
#include "orch.h"
#define EXAMPLE3 1
#define MAXINS 5
static double *a;
static long sampno;
static long base;
extern Str255 theMess1;
void initl()
{
register long j;
a = (double *)NewPtr(MAXINS * 29 * sizeof(double));
if ( a == 0L )
fprintf(stderr, "Not enough memory in initl\n");
for ( j = 0; j < MAXINS * 29; j++ )
*(a+j) = 0.0;
}
void setup()
{
/*
* p4 = pitch (in 8ve.pc)
* p5 = amp
* p6 = initial centre freq of BP filter
* p7 = final centre freq of BP filter
*
*/
switch(instype) {
case EXAMPLE3:
if ( insno > MAXINS ) {
sprintf((char *)theMess1, "Instrument number %d is out of range", insno);
CtoPstr((char *)theMess1);
OSError(theMess1, NIL, NIL );
}
base = ((insno-1) * 29);
*(a+base) = p[5] * 1000.0;
*(a+base+1) = pitch(p[4]);
*(a+base+2) = (int)(5000.0/cpspch(p[4]));
rsnset(0.0, 2500.0, 1.0, 0.0, (a+base+4));
*(a+base+9) = p[7] - p[6];
*(a+base+10) = period(p[3]);
*(a+base+11) = 0.0;
*(a+base+12) = p[6];
vrsset(*(a+base), 0.0, (a+base+13));
blnset(10.0, 0.0, (a+base+18));
evpset(0.025, 0.2, *(p+3), 0.2, 5, 5, (a+base+24));
break;
default:
/*fprintf(stderr, "error in instrument type number, %d\n", instype);*/
;
}
}
void orch()
{
register double x;
register double y;
register double sig;
register double z;
switch(instype) {
case EXAMPLE3:
base = ((insno-1) * 29);
x = buzz(*(a+base), *(a+base+1), *(a+base+2), 1, (a+base+3));
x = reson(x, (a+base+4));
y = oscil1(*(a+base+9), *(a+base+10), 3, (a+base+11)) + *(a+base+12);
z = vreson(x, y, y * 0.1, 2560.0, 4, (a+base+13));
x = balnce(z, x, (a+18));
sig = envlp(x, 5, 5, (a+base+24));
Mono(sig);
break;
default:
fprintf(stderr, "error in instrument type number, %d\n", instype);
}
}
void ter()
{
/* just gets called at the end a note for clean up etc. */
}
void final()
{
/* called at the end of the synth run.
* close any files etc. you haven't already closed here.
*/
}